package phi;

import method.*;
import java.util.Iterator;
import lib.Output;

public class PhiN {

    public int[] cptResult;
    public static int entiermax;

    public PhiN(int entiermax) {
        PhiN.entiermax = entiermax;
        cptResult = new int[ entiermax + 1 ];
        cptResult[2] = 0;
        cptResult[3] = 0;
        cptResult[4] = 0;
        cptResult[5] = 0;

        for (int n = 6 ; n <= entiermax ; n++) {
            cptResult[n] = card(new CalculateMethod(n));
        }
    }

    private int card(CalculateMethod factors) {
        int max = 0;
        for (Iterator<Integer> it = factors.keySet().iterator() ; it.hasNext() ;) {
            Output outputL = factors.get(it.next());

            if (outputL.multip >= max) {
                max = outputL.multip;
            }
        }

        return max;
    }

    @Override
    public String toString() {
        super.toString();
        String ret = "";
        for (int n = 2 ; n <= entiermax ; n++) {
            ret += n + "," + cptResult[n] + "\n";
        }
        return ret;
    }
}








